package sapling.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import sapling.model.Cost;
import sapling.model.Role;

import java.util.List;

/**
 * Created by ever on 2016/10/9.
 */
public interface CostDao extends JpaRepository<Cost, Long> {
    @Query(value = "SELECT * from cost ORDER BY entering_time desc",nativeQuery = true)
    List<Cost> findByEnteringTimeDesc();

    @Query(value = "SELECT SUM(waterrate+medicine+chemical+landrent+personrate+rests) FROM cost",nativeQuery = true)
    double sum();

    @Query(value = "SELECT * FROM cost WHERE entering_time BETWEEN ?1 AND ?2 order by entering_time desc",nativeQuery = true)
    List<Cost> findByDate(String date1,String date2);
}
